﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NMbsDuplex.TCPServerX
{
    using Deamon;
    using DrDimsLib.CoreSDK.Functionality;
    using MrPoetic.MatLab;
    using Net.AsyncPool;
    using Net.TencentOpenAPI;

    class Program
    {
        /// <summary>
        /// 调用 .NET 标准线程池技术
        /// </summary>
        static void ParalevelWork()
        {
            var worker = new MyThreadPool()
            {
                isJobsDone = false,
            };
            object val = DataMatrix._2TimesIMPL(24).LastOrDefault();
            worker.WorkItemWithPThreadID((obj) =>
            {
                Console.WriteLine("传入的参数类型{0} Val --->{1}", obj.GetType(), obj);
                val = Convert.ToInt32(obj) / 2;
                if (Convert.ToInt32(val) == 0)
                {
                    worker.isJobsDone = false;
                }
            }, ref val);
        }
        static void CommonTest()
        {
            // 1.对接 Tecent微信开放平台 获取Token
            IDevelopStart requester = new OpenAPIDeploy();
            var corpID = "ww127e21ef76d217fb";
            var appSecret = "IvcW3oJ8n8r5xNXqGPjLX_rGl9JD6ikz4htF4ENz4lc";
            requester.GetAccessToken(corpID, appSecret);

            // 2.测试C#中的 系统线程池技术
            // ParalevelWork();

            // 3.测试`双工通信Socket传输工具`
            IOUtilWorkFlow instance = new IOUtilWorkFlow();
            var files = instance.ScanFolderV2(null, false);
            Console.WriteLine();
        }

        static void Main(string[] args)
        {

            Task.Run(() =>
            {
                ParalevelWork();
            }).ContinueWith((task) =>
            {
                CommonTest();
                new Bifrost(33036);
            });
            while (true) ;
        }
    }
}
